home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
jdp1_4.zip
/
JDP1_4.EXE
/
data.1
/
JDPLayout4.java
< prev
next >
Wrap
Text File
|
1996-10-18
|
12KB
|
393 lines
>XXX0384 Total lines for the build status message calculation
//--------------------------------------------------------------------
//
>001// Module: <JDPModule>
>002// Description: <Class Description>
//
//--------------------------------------------------------------------
import java.awt.*;
import java.applet.*;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.Date;
>003public class <JDPUserBill> extends JDPClassLayout {
JDPUser user;
JDPJagg jaggSQL;
JDPTextGrid tableContents;
JDPWhereClause jdpWhereClause;
String[] psortChoice;
String[] pdisplayChoice;
int itemIndex;
boolean insertRequested = false;
boolean deleteRequested = false;
String pfromWhereClause;
String[][] rowKey;
int keyCount;
int prevColumnCount;
>119 int columnCount = <columnCount>;
Vector pmatchUsing;
Vector pactualmatchUsing;
public void InitClass(JDPUser user, Panel targetPanel, String moduleParameter) {
this.user = user;
//
// Set JAGG settings for this class
//
jaggSQL = new JDPJagg(user.jaggPath);
jaggSQL.setNULL("space");
>995 jaggSQL.setMRW("<maxRows>");
>998 jaggSQL.setDSN("<datasource>");
>999 jaggSQL.setCSTR("<connectstr>");
setLayout(new BorderLayout());
setFont(user.plainFont);
Panel mainPanel = new Panel();
mainPanel.setLayout(new BorderLayout());
Panel centerMainPanel = new Panel();
centerMainPanel.setLayout(new BorderLayout());
//
// Create a new instance of a Grid
//
tableContents = new JDPTextGrid(user);
mainPanel.add("Center",tableContents);
centerMainPanel.add("Center",mainPanel);
//
// Define parameters for JDPWhereClause
//
>016 String[] pchooseFrom = new String[<7>];
>017 pchooseFrom[<0>] = "<Account Name>";
>018 String[] pactualchooseFrom = new String[<7>];
>019 pactualchooseFrom[<0>] = "<username>";
loadMatchUsing();
>024 boolean[] constantIsString = new boolean[<7>];
>025 constantIsString[<0>] = <true>;
>026 int[] constantLength = new int[<7>];
>027 constantLength[<0>] = <20>;
//
// Add JDPWhereClause search panel
//
if (pchooseFrom.length > 0) {
>028 jdpWhereClause = new JDPWhereClause(user, targetPanel, "<UserBill>", false, "<pinitChoice>", pchooseFrom, pactualchooseFrom,
pmatchUsing, pactualmatchUsing, null, null,
constantLength, constantIsString);
centerMainPanel.add("North",jdpWhereClause);
}
>030 add("Center",new JDPChiselFramePanel(user,"<User Billing Details>",centerMainPanel,"North"));
loadGrid();
//
// Add the handle to this panel to the global vector so other panels can
// access this one
//
user.gParm.addElement(this);
}
//
// Handle screen events
//
public boolean handleEvent(Event e) {
switch (e.id) {
case Event.ACTION_EVENT:
if (e.target instanceof Button) {
String choice = (String)e.arg;
if (choice.trim().compareTo("Search") == 0) {
newSearch();
return true;
}
return false;
}
if (e.target instanceof Choice) {
return true;
}
if (e.target instanceof TextField) {
if ((jdpWhereClause != null) && (e.target.equals(jdpWhereClause.matchConstant))) {
newSearch();
return true;
}
return true;
}
return false;
case Event.WINDOW_EXPOSE:
if (e.target instanceof JDPTabSelectPanel) {
//
// This is where you place code to get executed when this panel is
// reactivated from the tab menu
//
return true;
}
return false;
default:
return false;
}
}
//
// Retrieve the handle to another panel so as to be able to interact with it
//
public void retrieveHandle() {
for (int ix=0; ix<user.gParm.size(); ix++) {
//
// Activate the next four lines of code to retrieve the handle to another
// Panel within your JDP system. Of course you should declare the variable
// at the top of this source instead of within this method so you can
// access it from all the methods within this class. You only need to
// substitute DemoClass with the name ouf your class. You should call this
// method from somewhere else in this class. To access a variable from
// your resulting class use:
// if (DemoClassHandle != null) mynewvar = demoClassHandle.variable;
//
// if (user.gParm.elementAt(ix) instanceof DemoClass19) {
// DemoClass19 DemoClassHandle = (DemoClass19)user.gParm.elementAt(ix);
// return;
// }
}
}
//
// The search button was pressed so rerun the query with the new search criteria
//
public void newSearch() {
loadGrid();
}
//
// Load the grid with the specified parameters and selected data
//
public void loadGrid() {
StringTokenizer stok;
int recCount = 0;
Vector results = new Vector();
String sep = jaggSQL.getSEP();
int actualRows = 0;
String row;
float[][] worksubTotal;
float[][] workgrandTotal;
Vector columns = new Vector();
Vector indexes = new Vector();
>100 String SQL = <SELECT>;
user.mainmsg.setStatusMsg("Accessing database...", 0);
recCount = jaggSQL.execSQL(SQL, results);
if(recCount == -1) {
user.u.setSqlMessage(jaggSQL,SQL);
return;
}
//
// Initialise result arrays
//
actualRows = jaggSQL.getRowCount();
tableContents.currentText = new String[columnCount][actualRows+30];
tableContents.cellFont = new Font[columnCount][actualRows+30];
tableContents.gridColor = Color.white;
boolean[] totalThisColumn = new boolean[columnCount];
//
// If we haven't already initialise the grid settings
//
if (columnCount != prevColumnCount) {
prevColumnCount = columnCount;
setGridSettings();
}
String[] lastItem = new String[columnCount];
>125 boolean[] subTotal = new boolean[<>];
>125 boolean[] grandTotal = new boolean[<>];
>126 int orderBy = <>;
>127 subTotal[<>] = <>;
>128 grandTotal[<>] = <>;
>129 totalThisColumn[<>] = <>;
//
// Load arrays and result List
//
worksubTotal = new float[1][1];
workgrandTotal = new float[1][1];
int xOffset = 0;
int xIncrement = 0;
int titlePos = (int)(columnCount/2)-1;
if (titlePos < 0) titlePos = 0;
>124 tableContents.currentText[titlePos][1] = "<>";
tableContents.cellFont[titlePos][1] = new Font(user.plainFont.getName(),Font.BOLD,user.plainFont.getSize()+4);
for (int iy=0; iy<columnCount; iy++) {
tableContents.cellFont[iy][3] = user.boldFont;
}
>101 tableContents.currentText[<ix>][3] = "<>";
xOffset = 4;
worksubTotal = new float[orderBy][columnCount];
workgrandTotal = new float[orderBy][columnCount];
int ix;
for (ix=0; ix<actualRows; ix++) {
row = (String)results.elementAt(ix);
if ((row != null) && (row.trim().compareTo("") != 0)) {
stok = new StringTokenizer(row);
for (int iy=0; iy<columnCount; iy++) {
tableContents.currentText[iy][ix+xOffset] = stok.nextToken(sep).trim();
}
for (int iy=columnCount-1; iy>=0; iy--) {
String thisItem = tableContents.currentText[iy][ix+xOffset];
if ((orderBy > iy) && (ix > 0)) {
if (thisItem.equals(lastItem[iy])) {
tableContents.currentText[iy][ix+xOffset] = "";
} else {
if (subTotal[iy]) {
for (int iz=0; iz<columnCount; iz++) {
tableContents.currentText[iz][ix+xOffset+1] = tableContents.currentText[iz][ix+xOffset];
tableContents.currentText[iz][ix+xOffset] = "";
tableContents.cellFont[iz][ix+xOffset+1] = tableContents.cellFont[iz][ix+xOffset];
tableContents.cellFont[iz][ix+xOffset] = null;
}
tableContents.currentText[iy][ix+xOffset] = "Subtotal";
tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
for (int iw=iy+1; iw<columnCount; iw++) {
if (totalThisColumn[iw]) {
tableContents.currentText[iw][ix+xOffset] = user.u.str(worksubTotal[iy][iw],11,3).trim();
tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
}
worksubTotal[iy][iw] = 0;
}
xOffset += 1;
}
tableContents.currentText[iy][ix+xOffset] = thisItem;
}
}
if ((orderBy > 0) && (ix > 0)) {
try {
float tempfloat = Float.valueOf(lastItem[iy]).floatValue();
for (int iz=0; iz<orderBy; iz++) {
worksubTotal[iz][iy] += tempfloat;
workgrandTotal[iz][iy] += tempfloat;
}
} catch(Exception e) {
}
}
lastItem[iy] = thisItem;
}
}
}
for (int iy=0; iy<columnCount; iy++) {
try {
float tempfloat = Float.valueOf(lastItem[iy]).floatValue();
for (int iz=0; iz<orderBy; iz++) {
worksubTotal[iz][iy] += tempfloat;
workgrandTotal[iz][iy] += tempfloat;
}
} catch(Exception e) {
}
}
for (int iy=columnCount-1; iy>=0; iy--) {
if (orderBy > iy) {
if (subTotal[iy]) {
tableContents.currentText[iy][ix+xOffset] = "Subtotal";
tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
for (int iw=iy+1; iw<columnCount; iw++) {
if (totalThisColumn[iw]) {
tableContents.currentText[iw][ix+xOffset] = user.u.str(worksubTotal[iy][iw],11,3).trim();
tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
}
}
xOffset += 1;
}
}
}
for (int iy=columnCount-1; iy>=0; iy--) {
if (orderBy > iy) {
if (grandTotal[iy]) {
tableContents.currentText[iy][ix+xOffset] = "Total";
tableContents.cellFont[iy][ix+xOffset] = user.boldFont;
for (int iw=iy+1; iw<columnCount; iw++) {
if (totalThisColumn[iw]) {
tableContents.currentText[iw][ix+xOffset] = user.u.str(workgrandTotal[iy][iw],11,3).trim();
tableContents.cellFont[iw][ix+xOffset] = user.boldFont;
}
}
xOffset++;
}
}
}
tableContents.newTable();
//
// Clear status message
//
user.mainmsg.clearStatusMsg();
}
//
// Set up the parameters for this grid
//
public void setGridSettings() {
tableContents.columnHeader = null;
tableContents.columnHeaderStyle = new int[columnCount];
tableContents.columnStyle = new int[columnCount];
tableContents.columnHeaderColor = new Color[columnCount];
tableContents.columnColor = new Color[columnCount];
tableContents.columnBGColor = new Color[columnCount];
tableContents.columnProtected = new boolean[columnCount];
tableContents.columnWidth = new int[columnCount];
tableContents.rightJustify = new boolean[columnCount];
tableContents.rowHeader = null;
tableContents.columnHeight = null;
for (int ix=0; ix<columnCount; ix++) {
tableContents.columnHeaderStyle[ix] = Font.BOLD;
tableContents.columnStyle[ix] = Font.PLAIN;
tableContents.columnHeaderColor[ix] = Color.black;
tableContents.columnColor[ix] = Color.black;
tableContents.columnBGColor[ix] = Color.white;
tableContents.columnStyle[ix] = Font.PLAIN;
}
>102 tableContents.columnHeaderStyle[<ix>] = <>;
>103 tableContents.columnStyle[<ix>] = <>;
>104 tableContents.columnHeaderColor[<ix>] = user.u._cvtcolor("<>");
>105 tableContents.columnColor[<ix>] = user.u._cvtcolor("<>");
>106 tableContents.columnBGColor[<ix>] = user.u._cvtcolor("<>");
>107 tableContents.columnProtected[<ix>] = <>;
>108 tableContents.columnWidth[<ix>] = <>;
>109 tableContents.rightJustify[<ix>] = <>;
}
//
// Load the Search Layout pulldown choices
//
public void loadMatchUsing() {
pmatchUsing = new Vector();
pactualmatchUsing = new Vector();
>020 pmatchUsing.addElement(new Vector());
>022 pactualmatchUsing.addElement(new Vector());
>021 ((Vector)pmatchUsing.elementAt(<0>)).addElement("<Begins with>");
>023 ((Vector)pactualmatchUsing.elementAt(<0>)).addElement("< like >");
}
}